package leetcode.bfs;

import leetcode.bfs.common.BFSUtils;
import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution700 {
    public TreeNode searchBST(TreeNode root, int val) {
        return BFSUtils.searchBST(root, val);
    }
}

public class leetcode700 {
    public static void main(String[] args) {
        Solution700 solution700 = new Solution700();
        Integer[] nums = {4, 2, 7, 1, 3};
        test700(solution700, nums, 2);
        test700(solution700, nums, 8);
    }

    private static void test700(Solution700 solution700, Integer[] nums, int val) {
        TreeNode root = solution700.searchBST(TreeUtils.generateLeetcodeTree(nums), val);
        System.out.println(TreeUtils.getLeetcodeTreeVals(root));
    }
}
